<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8"/>
		<title>
			Document
		</title>
	</head>
	<body>
		<form id='form1'>
			<div id='div1'></div>
			<div id='div2'></div>
			<div id='div3'></div>
			<div id='div4'></div>
			<div id='div5'></div>
			<div id='div3'>
				id名重复的元素
			</div>
		</form>
		<script>
			var list = document.querySelectorAll("*");
			for(var i = 0;i<list.length;i++){
				if(list[i].id){
					var a = document.querySelectorAll("#"+list[i].id);
					if(a.length>1){
						console.log(list[i].id+"重复了");
					}
				}
			};

			</script>
	</body>
	<!-- 用程序实现找到html中id名相同的元素？ -->
</html>
